package cn.edu.imau.zy.examination.controller;

import java.util.List;
import java.util.Arrays;


import cn.edu.imau.zy.examination.domain.ElPaperQu;
import cn.edu.imau.zy.examination.service.IElPaperQuService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import cn.edu.imau.zy.common.core.domain.R;
import cn.edu.imau.zy.common.core.controller.BaseController;


/**
 * 试卷考题 提供者
 * 
 * @author xsc
 * @date 2021-04-27
 */
@RestController
@RequestMapping("qu")
public class ElPaperQuController extends BaseController
{
	
	@Autowired
	private IElPaperQuService elPaperQuService;
	
	/**
	 * 查询
	 */
	@GetMapping("get/{id}")
	public ElPaperQu get(@PathVariable("id") String id)
	{
		return elPaperQuService.getById(id);
		
	}

	@GetMapping("getPaperQu/{id}")
	public R getPaperQu(@PathVariable("id") String id){

//		return R.data(elPaperQuService.list(new QueryWrapper<ElPaperQu>().eq("paper_id",id)));
		return R.data(elPaperQuService.paperQuList(id));
	}
	
	/**
	 * 查询试卷考题列表
	 */
	@GetMapping("list")
	public R list(ElPaperQu elPaperQu)
	{
		startPage();
        return result(elPaperQuService.queryList(elPaperQu));
	}
	
	
	/**
	 * 新增保存试卷考题
	 */
	@PostMapping("save")
	public R addSave(@RequestBody ElPaperQu elPaperQu)
	{
//		elPaperQu.setCreateBy(user.getUserId().toString());
		return toAjax(elPaperQuService.save(elPaperQu));
	}

	/**
	 * 修改保存试卷考题
	 */
	@PostMapping("update")
	public R editSave(@RequestBody ElPaperQu elPaperQu)
	{
//		elPaperQu.setUpdateBy(user.getUserId().toString());
		return toAjax(elPaperQuService.updateById(elPaperQu));
	}
	
	/**
	 * 删除${tableComment}
	 */
	@PostMapping("remove")
	public R remove(String ids)
	{		
		return toAjax(elPaperQuService.removeById(ids));
	}
	
}
